<template>
    <div class="list1">
        <!-- 头部 -->
        <!-- <div class="header">
            <x-icon type="ios-arrow-left" size="" class="icon-white" @click="$router.go(-1)"></x-icon>选择检查单位
        </div> -->
        <!-- 内容部分 -->
        <div class="list1_main">
            <!-- <noData v-if="listArr == 0"></noData> -->
            <div class="searchDiv"  v-if="input">
                <input type="text" v-model="param.data.name" class="search" placeholder="输入关键字搜索">
            </div>
            <div class="list1Box">
                <group>
                    <radio :options="listArr" @on-change="change" v-model="radios"></radio>
                </group>
            </div>
        </div>
        <myMenu @clickBack="back"></myMenu>
    </div>
</template>
<script>
import { Radio, Group, Actionsheet } from 'vux'

import myMenu from '@/commonComponents/menu'
export default {
    components: {
        Radio,
        Group,
        myMenu
    },
  data () {
      return {
        radios: '',
        // ab:[{a:'11',b:'222'},{a:'33',b:'44'}],
        param: {
            allowPaging: true,
            business: 'GetDepartsX',
            data: {
                deptId: '',
                name: ''
            },
            pageIndex: 0,
            pageSize: 10000,
            tokenId: 'D0853C0CE5A6A478F5C613B840394FC3',
            userId: ''
        },
        listArr: [],
        list: [],
        input: false
      }
  },
  mounted () {
      var token = JSON.parse(window.localStorage.getItem('userInfo'))
      if (token.departsir == 1) {
          this.input = true
      }
      this.param.userId = token.userid
      this.param.data.deptId = token.deptid
      this.dataArr()
      this.radios = window.sessionStorage.getItem('name1')
  },
  methods: {
    back () {

    },
    change (value, label) {
        console.log('change:', value, label)
        if (value) {
            window.sessionStorage.setItem('name1', value)
        }
        for (var k in this.list) {
            if (this.list[k].deptName == value) {
               window.sessionStorage.setItem('id1', this.list[k].deptId)
               this.$router.go(-1)
            }
        }
    },
    dataArr () {
      this.$axiosAjax.getConfigJson(this.param).then((res) => {
            if (res.status) {
                this.list = res.data.data
                var arr = res.data.data
                var array = []
                for (var k in arr) {
                    array.push(arr[k].deptName)
                }
                this.listArr = array
            }
         }
      )
    }
  },
    watch: {
      'param.data.name' (val) {
          this.dataArr()
      }
  }
}
function getResult (val) {
  let rs = []
  for (let i = 0; i < 20; i++) {
    rs.push({
      title: `${val} result: ${i + 1} `,
      other: i
    })
  }
  return rs
}
</script>
<style lang="less" scope>
.list1{
    width: 100%;
    height: 100%;
    background-color: #ebeef2;
    .list1_main{
        // height: 627px;
        width: 100%;
        background-color: #ebeef2;
        .searchDiv{
            background-color: #ebeef2;
            padding: 10px 0;
            .search{
                width: 360px;
                margin: 0 auto;
                height: 40px;
                line-height: 40px;
                padding-left: 10px;
                box-sizing: border-box;
                border-radius: 10px;
                display: block;
                border: 1px solid #999;
            }
        }

        .list1Box{
            width: 100%;
            // height: 627px;
            background-color: #ebeef2;
            .weui-search-bar__cancel-btn{
                display: none;
            }
            .weui-cells{
                margin-top: 2px;
            }
        }
    }
    .weui-cell:before{
        left: 0;
    }
    .weui-cell__bd p{
        width: 316px;
    }
}
</style>
